{// 引入标签库 }
<tagLib name="html" />
{// 加载头部公共文件 }
<include file="Public:top" />
<!-- 菜单区域  -->

<!-- 主页面开始 -->
<div id="main" class="" >

<!-- 主体内容  -->
<div class="content" >
<div class="title">————相关信息与通知————</div>
<!--  功能操作区域  -->
<div class="operate" >
<!--<html:imageBtn name="add" value="新增" click="add()" style="impBtn hMargin fLeft shadow" />-->
<!--<html:imageBtn name="edit" value="编辑" click="edit()" style="impBtn hMargin fLeft shadow" />-->
<!--<html:imageBtn name="delete" value="删除" click="del()" style="impBtn hMargin fLeft shadow" />-->
<!--<html:imageBtn name="foreverdel" value="永久删除" click="foreverdel()" style="impBtn hMargin fLeft shadow small" />-->

</div>
<!-- 功能操作区域结束 -->
<style>
#newsList {
	margin:0px; padding:0px;
 float: left;
 height: auto;
 width: 100%;
}
#left {
 float: left;
 height: 500px;
 width: 32%; 
 margin-top:5px;
}
#right {
 float: left; padding:10px;
 min-height: 500px;
 width: 62%;
 border: 1px solid #333;
}
#left li {
 height:30px; line-height:30px; cursor:pointer; padding:0 5px 0 5px; overflow:hidden; float:left; width:100%;
}
.curTitle{ background-color:#333; color:#FFF;}
#pagediv{ text-align:left;}
#opdiv{padding:5px 0px 10px 5px;}
</style>
<!-- 列表显示区域  -->
<div class="list" id="newsList">
	<div id="left">
      <volist name = 'newslist' id='vo'><li data-id='{$vo.id}' data-title='{$vo.title}'>·{$vo.title}[{$vo.updateDate|toDate='Y-m-d'}]</li></volist>
    </div>
    <div id="right">
    	<div id="opdiv"><a href="#" id="addNewsButton" f="content" s="添加通知">添加通知</a>&nbsp;&nbsp;<a href="#" id="editNewsButton" f="content" s="编辑通知">编辑通知</a>&nbsp;&nbsp;<a href="#" id="delNewsButton" f="content" s="删除通知">删除通知</a></div>
    	<div id="content"></div>
    </div>
</div>
<!--  分页显示区域 -->
<div class="page" id="pagediv">{$page}</div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束 -->
<include file="Public:footer" />
<style>
.dlg{ height:480px; width:930px; top:2px; position:static; float:left;}
.dlg1{ height:460px; width:910px; float:left;}
#div_title{height:30px; line-height:30px; width:99%; margin:5px 0px;}
#div_title input{height:24px; line-height:24px; width:98%}
</style>
<div class="hide" style="height:100%" id="hideDiv">
    <div id="dlg_content" class="dlg">
    	<div id="div_title"><input name="title" id="title" type="text" class="large" value="这里输入标题，下方输入通知正文！" /></div>
    	<div id="div_content" class="dlg1" f='content'></div>
    </div>
    <div id="tempDiv"></div>
</div>
<script>
var editor;
$(function(){
	$('#left li').click(function(){
		$('.curTitle').removeClass('curTitle');
		$(this).addClass('curTitle');	
		$.post("__URL__/myGetField",{id:$(this).data('id'),f:'content'},function(d){
			if(d.status){ 
				$('#content').html(d.data).hide();
				$('#content').fadeIn(1000, function(){ });
			}
		},"json");
	})
	$('#left li').hover(
		function(){ $(this).addClass('over')},
		function(){ $(this).removeClass('over')}
	);
	$('#addNewsButton').click(function(){
		var ff = $(this).attr("f");//f用于表示操作的字段，
		var sf = $(this).attr("s");//s用于显示的标题
		$('#dlg_'+ff).unbind().dialog({
			onOpen:function(){
				$("html,body").animate({scrollTop:$("body").offset().top},1000);//1000是ms,也可以用slow代替
				$('html').addClass('hidescroll');
			},
			onClose:function(){
				$('html').removeClass('hidescroll');
				$('#title').val('这里输入标题，下方输入通知正文！');
				if(editor){ 
					//$('#div_'+ff).html(editor.html());
					editor.remove();
					editor = null;
					window.location.reload();
				}
			},
			modal:true,title:sf+"对话框",width:910,height:600,maximizable:true,resizable:true,shadow:true,
			buttons:[{
				text:'保存',iconCls:'icon-ok',
				handler:function(){
					if(!editor){ $('#dlg_'+ff).dialog('close');return;}else{ $('#content').val(editor.html());}
					$.post("__URL__/insert/",{title:$('#title').val(),content:$('#content').val()},function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
						if(data.status){ $('#dlg_'+ff).dialog('close');}
					}//function
					,"json");//post	
				}
			},{
				text:'关闭',handler:function(){
					$('#dlg_'+ff).dialog('close');
				}
			}]
		});	
		//不足5个字符时直接显示编辑器
		editor = showEditor(ff,0,455);		
	});//click
	$('#delNewsButton').click(function(){
		var id = $('.curTitle').data('id');
		var ti = $('.curTitle').data('title');	
		$.messager.confirm('信息提示', '你确定要删除此信息吗？<br>'+ti, function(r){
			if (r){
				$.get("__URL__/delete/",{id:id},function(data){
					$('.curTitle').remove();
					$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
					$('#left li:first').trigger('click');
				}//function
				,"json");//post	
			}//if
		});//confirm
	});//click
	
	$('#editNewsButton').click(function(){
		var ff = 'content';//f用于表示操作的字段，
		var sf = '编辑通知';
		var id = $('.curTitle').data('id');
		$('#title').val($('.curTitle').data('title'));
		$('#div_content').html($('#content').html());
		$('#dlg_'+ff).unbind().dialog({
			onOpen:function(){
				$("html,body").animate({scrollTop:$("body").offset().top},1000);//1000是ms,也可以用slow代替
				$('html').addClass('hidescroll');
				},
			onClose:function(){
				if(editor){ 
					editor.remove();$('#div_content').html('');
					editor = null;
					$('.curTitle').trigger('click');
					$('.curTitle').html($('#title').val());
					$('.curTitle').data('title',$('#title').val());
				}
				$('html').removeClass('hidescroll');
				$('#title').val('这里输入标题，下方输入通知正文！');
			},
			modal:true,title:sf+"对话框",width:910,height:600,maximizable:true,resizable:true,
			buttons:[{
				text:'保存',iconCls:'icon-ok',
				handler:function(){
					if(!editor){ $('#dlg_'+ff).dialog('close');return;}else{ $('#content').val(editor.html());}
					$.post("__URL__/update/",{id:id,title:$('#title').val(),content:$('#content').val()},function(data){
						$.messager.show({title:'提示信息',msg:data.info,timeout:2000,showType:'slide'});
						if(data.status){ $('#dlg_'+ff).dialog('close');}
					}//function
					,"json");//post	
				}
			},{
				text:'关闭',handler:function(){
					$('#dlg_'+ff).dialog('close');
				}
			}]
		});	
		//不足5个字符时直接显示编辑器
		editor = showEditor(ff,0,455);
	});
	
	$('#left li:first').trigger('click');//选中第一个新闻
	$("#title").focus(function () { 
		$(this).css("background", "#F5F5F5");
		if($(this).val()=='这里输入标题，下方输入通知正文！'){
			$(this).val('');
		}
	 }).blur(function () { $(this).css("background", "#fff"); })
})
</script>